package org.budo.solr.jdbc.driver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import org.budo.jdbc.driver.AbstractBudoJdbcDriver;
import org.budo.solr.jdbc.driver.parser.jsqlparser.JsqlParserSolrStatementParser;

/**
 * @author lmw
 */
public class BudoSolrJdbcDriver extends AbstractBudoJdbcDriver {
    static {
        try {
            DriverManager.registerDriver(new BudoSolrJdbcDriver()); // 类加载时注册驱动
        } catch (Throwable e) {
            throw new IllegalStateException("#38 Can't register driver!", e);
        }
    }

    @Override
    public Connection connect(String url, Properties info) throws SQLException {
        BudoSolrJdbcConnection connection = new BudoSolrJdbcConnection();
        connection.setStatementParser(new JsqlParserSolrStatementParser());
        return connection;
    }
}